package com.wis.controller;

import com.wis.entity.CourseEntity;
import com.wis.service.CourseService;
import com.wis.util.CommonResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/course")
public class CourseController {
    @Autowired
    private CourseService courseService;

    @GetMapping("/selectCourseByName")
    public CommonResult selectCourseByName(@RequestParam(required = false) String name,
                                                       @RequestParam(defaultValue = "1") Integer page,
                                                       @RequestParam(defaultValue = "10") Integer limit){

        return courseService.selectCourseByName(name,page,limit);
    }

    /**
     * 删除
     * **/
    @PostMapping("/delCourse/{id}")
    public CommonResult delCourse(@PathVariable Integer id){
        return courseService.delCourse(id);
    }

    /**
     * 更新
     * **/
    @PostMapping("/updateCourse")
    public CommonResult updateNotice(@RequestBody CourseEntity course) {
        return courseService.updateCourse(course);
    }
    /**
     * 增加
     * **/
    @PostMapping("/addCourse")
    public CommonResult addCourse(@RequestBody CourseEntity course) {
        return courseService.addCourse(course);
    }
}
